package com.itheima.springboot_13_configuration.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;

@Component //这个类要受到spring的管控
@Data //简化了属性的get和set写法
@ConfigurationProperties(prefix = "servers")//配置文件中有很多,如何获取特定片段
@Validated //开启数据校验功能
public class ServerConfig {
    private String ipAddress;
    @Min(value =30000,message = "最小30000")
    @Max(value =40000,message = "最大40000")
    @NotEmpty //不允许为空
    private int port;
    private long timeout;
}
